<?php

class CollectionSubmitAction extends SzAbstractAction
{
    protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
    );

    /**
     * 提交物品
     *
     * @param int $userId
     * @param int $itemId 要合成的物品
     * @param int $appointedItem 物品Id
     * @param int $appointedCount 数量
     * @param int $reqTime
     * @return SzResponse
     */
    public function execute($userId, $itemId, $appointedItem, $appointedCount, $reqTime)
    {
        if (!GameService::get()->verifySysUnlock($userId, GameConst::FUNC_COLLECTION_FUNC)) {
            return $this->buildResponse(false);
        }

        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);

        $collection = CollectionService::get()->submit($userId, $itemId, $appointedItem, $appointedCount);
        return $this->buildResponse(array(
            'collectionVo' => $collection->toArray(),
        ));
    }
}